<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

/*
 * 后台路由
 * */

use think\facade\Route;
Route::rule('/',function (){echo "欢迎来到测评官网";});



Route::group('admin',function (){
    Route::get('/','backend/Index/index');

    Route::get('/login','backend/Login/index');
    Route::post('/login/deal','backend/Login/deal');
    Route::get('/changePwd','backend/Login/changePwd');
    Route::post('/changePwdPost','backend/Login/changePwdPost');
    Route::get('/logout','backend/Login/logout');

    //测评明细
    Route::get('/topic','backend/Topic/index');
    Route::get('/topic/add','backend/Topic/add');
    Route::post('/topic/save','backend/Topic/save');
    Route::get('/topic/edit/:id','backend/Topic/edit',[],['id'=>'\d+']);
    Route::post('/topic/update/:id','backend/Topic/update',[],['id'=>'\d+']);
    Route::post('/topic/del','backend/Topic/del');
    Route::post('/topic/deal','backend/Topic/deal_attr');
    Route::post('/topic/sort/:id','backend/Topic/sort',[],['id'=>'\d+']);
    Route::get('/topic/question/:id','backend/Topic/question',[],['id'=>'\d+']);
    Route::get('/topic/answer/:id','backend/Topic/answer',[],['id'=>'\d+']);
    Route::any('/topic/saveQuestion','backend/Topic/saveQuestion');
    Route::any('/topic/saveAnswer','backend/Topic/saveAnswer');
    Route::post('/topic/dealAttr','backend/Topic/dealAttr');
    Route::any('/topic/createWechatUrl','backend/Topic/createWechatUrl');
    Route::any('/topic/createMedia','backend/Topic/createMedia');

    //首页banner
    Route::get('/banner','backend/Banner/index');
    Route::get('/banner/add','backend/Banner/add');
    Route::get('/banner/edit/:id','backend/Banner/edit',[],['id'=>'\d+']);
    Route::post('/banner/del','backend/Banner/del');
    Route::post('/banner/deal','backend/Banner/deal');

    //测评分类管理
    Route::get('/topicCate','backend/TopicCate/index');
    Route::get('/topicCate/add','backend/TopicCate/add');
    Route::get('/topicCate/edit/:id','backend/TopicCate/edit',[],['id'=>'\d+']);
    Route::post('/topicCate/del','backend/TopicCate/del');
    Route::post('/topicCate/deal','backend/TopicCate/deal');

    //头条用户明细
    Route::get('/user','backend/User/index');
    Route::get('/user/details/:id','backend/User/details',[],['id'=>'\d+']);
    Route::get('/user/person/:id','backend/User/person',[],['id'=>'\d+']);


    //系统配置
    Route::get('/config','backend/Config/index');
    Route::post('/config/save','backend/Config/save');

    //权限管理
    Route::get("/permission/list","backend/Permission/index");
    Route::get("/permission/add","backend/Permission/add");
    Route::get("/permission/:id/edit","backend/Permission/edit",[],['id'=>'\d+']);
    Route::post("/permission/deal","backend/Permission/deal");
    Route::post("/permission/:id/delete","backend/Permission/delete",[],['id'=>'\d+']);

    //角色管理
    Route::get("/roles/list","backend/Roles/index");
    Route::get("/roles/add","backend/Roles/add");
    Route::get("/roles/:id/edit","backend/Roles/edit",[],['id'=>'\d+']);
    Route::post("/roles/deal","backend/Roles/deal");
    Route::post("/roles/:id/delete","backend/Roles/delete",[],['id'=>'\d+']);

    //管理员管理
    Route::get("/admin/list","backend/Admin/index");
    Route::get("/admin/add","backend/Admin/add");
    Route::get("/admin/:id/edit","backend/Admin/edit",[],['id'=>'\d+']);
    Route::post("/admin/deal","backend/Admin/deal");
    Route::post("/admin/:id/delete","backend/Admin/delete",[],['id'=>'\d+']);
})
    ->middleware(['SessionDeal:admin','AdminLogin','PermissionCheck']);


/*
 * api路由
 * */
Route::group('/api',function (){
    //用户手机绑定
    Route::rule('/user/status','api/User/checkUserLevel','get|post');
    Route::rule('/user/bindPhone','api/User/bindPhone','post');
    Route::rule('/user/resetPwd','api/User/editUserPassword','post');

    Route::rule('/topic/list','api/index/index',"get|post");
    Route::rule('/topic/search','api/index/search',"get|post");
    Route::rule('/topic/cateSearch','api/index/cateSearch',"get|post");
    Route::rule('/topic/details','api/index/getTopicDetail',"get|post");
    Route::rule('/topic/getImg','api/index/getResultImg',"get|post");
    Route::rule('/topic/getPlayLog','api/index/getPlayLog',"get|post");
    Route::rule('/topic/randomTopic','api/index/randomTopic',"get|post");
    Route::rule('/topic/cate','api/index/getTopicCate',"get|post");//首页分类
    Route::rule('/topic/cate/list','api/index/getTopicCateList',"get|post");//分类列表

    Route::rule('/getOpenid','api/index/getOpenId',"get|post");
    Route::rule('/saveUserInfo','api/index/saveUserInfo',"get|post");

    Route::rule('/getWechatSub','api/index/getWechatInfo',"get|post");




    /*通过签名验证的接口*/
    Route::group('',function (){
    })->middleware(['SignValidator']);


    //图片上传接口
    Route::rule('/fileUpload','api/fileUpload/upload',"get|post");

})
    ->middleware(['SessionDeal:api','Cors']);

return [

];
